package com.benio.ycfdisplayer.fresco;

import com.benio.ycfdisplayer.displayer.DisplayListener;
import com.benio.ycfdisplayer.displayer.Options;
import com.benio.ycfdisplayer.displayer.Target;
import com.facebook.drawee.interfaces.DraweeController;

/**
 * An Executor that loads image into {@link FrescoViewTarget}.
 * Created by benio on 2016/10/3.
 */
public class FrescoExecutor extends BitmapExecutor {

    public FrescoExecutor() {
    }

    @Override
    protected void execute(String uriString, Target target, Options options, DisplayListener listener) {
        // 判断如果是FrescoViewTarget的话则处理掉，否则转交父类处理
        if (target instanceof FrescoViewTarget) {
            FrescoViewTarget frescoViewTarget = (FrescoViewTarget) target;
            DraweeController newController = FrescoOptionsApplier.newControllerBuilder(uriString, frescoViewTarget, options, listener).build();
            frescoViewTarget.setController(newController);
        } else {
            super.execute(uriString, target, options, listener);
        }
    }
}
